namespace ScrumSprintMonitor.TestbenchApp.Views.TestbenchView
{
	#region #using Directives

	using System;
	using System.Windows;

	#endregion

	/// <summary>
	/// Interaction logic for TestbenchWindow.xaml
	/// </summary>
	public partial class TestbenchWindow : Window
	{
		private bool preventActivationReentrancy;

		public TestbenchWindow()
		{
			InitializeComponent();
		}

		public Window ParentWindow { get; set; }

		private void Window_Activated(object sender, EventArgs e)
		{
			// Make sure we show the ParentWindow beneath us when we are activated
			if (ParentWindow != null && ParentWindow.IsVisible && !this.preventActivationReentrancy)
			{
				this.preventActivationReentrancy = true;

				try
				{
					var prevOwner = Owner;
					Owner = ParentWindow;
					ParentWindow.Activate();
					Owner = prevOwner;
					Activate();
				}
				finally
				{
					this.preventActivationReentrancy = false;
				}
			}
		}

		private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
		{
			DragMove();
		}
	}
}